define(function (require) {

    "use strict";

    var $                       = require('jquery'),
        _                       = require('underscore'),
        Backbone                = require('backbone'),
        NewsCollection          = require('app/models/newslist'),
        NewsView                = require('app/views/news');

    return Backbone.View.extend({

        initialize: function () {            
            this.collection = new NewsCollection();            
		    this.collection.fetch();
		    this.render();
		    this.listenTo( this.collection, 'add', this.renderBook );
			this.listenTo( this.collection, 'reset', this.render );
        },
        render: function() {
		    this.$el.empty();
		    this.collection.each(function( item ) {
                    this.renderBook( item );
            }, this );	    
	    },	
	    renderBook: function( item ) {
		    var newsView = new NewsView({
			    model: item
		    });		    
		    this.$el.append( newsView.render().el );
	    }
        });

});

